package com.pro.service.imple;

import com.google.gson.Gson;
import com.pro.mapper.JsDeptListMapper;
import com.pro.pojo.JsDept;
import com.pro.pojo.JsDeptAuthority;
import com.pro.service.JsDeptListService;
import com.pro.utils.RedisCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * ClassName:JsDeptListServiceImple
 * Package:com.pro.service.imple
 * Description:
 *
 * @Date:2021/11/14 20:54
 * @Author: XJR
 */
@Service
public class JsDeptListServiceImple implements JsDeptListService {
    @Autowired
    private JsDeptListMapper mapper;

    @Autowired
    private RedisCache redisCache;

    private Gson gson = new Gson();

    //查看部门信息
    public List<JsDept> selectJsDeptList(String deptName, String trueName, String createDate, String status){
        List<JsDept> jsDepts = mapper.selectJsDeptList(deptName, trueName, createDate, status);
        redisCache.setCacheObject("DeptListSelectJsDeptList",gson.toJson(jsDepts));
        return jsDepts;
    };
    public Integer countJsDeptList(String deptName, String trueName, String createDate, String status){
        Integer integer = mapper.countJsDeptList(deptName, trueName, createDate, status);
        redisCache.setCacheObject("DeptListCountJsDeptList",integer);
        return integer;
    };

    //修改状态
    public Boolean updateJsDeptListStatus(JsDept jsDept){
        Boolean aBoolean = mapper.updateJsDeptListStatus(jsDept);
        return aBoolean;
    };

    //编辑
        //通过id查询
        public JsDept selectJsDept (Integer id){
            JsDept jsDept = mapper.selectJsDept(id);
            return jsDept;
        };
        //编辑
        public Boolean updateJsDept(JsDept jsDept){
            Boolean aBoolean = mapper.updateJsDept(jsDept);
            return aBoolean;
        };

    //删除
    public Boolean delJsDeptList(Integer id){
        Boolean aBoolean = mapper.delJsDeptList(id);
        return aBoolean;
    };

    //添加部门信息
    public Boolean addJsDeptList(JsDept jsDept){
        Boolean aBoolean = mapper.addJsDeptList(jsDept);
        return aBoolean;
    };
    public Boolean addJsDeptAuthority(JsDeptAuthority jsDeptAuthority){
        Boolean aBoolean = mapper.addJsDeptAuthority(jsDeptAuthority);
        return aBoolean;
    };
}
